home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / GCC 1.37.1r14 / usr / gcc-1.37.1r14 / (gcc-1.37.π) / symseg.h < prev    next >
Encoding:
Text File  |  1993-07-02  |  13.1 KB  |  229 lines  |  [TEXT/KAHL]

  1. AR PURPOSE.  See the
  2. GNU General Public License for more details.
  3.  
  4. You should have received a copy of the GNU General Public License
  5. along with GNU CC; see the file COPYING.  If not, write to
  6. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  7.  
  8. /* Format of GDB symbol table data.
  9.    There is one symbol segment for each source file or
  10.    independant compilation.  These segments are simply concatenated
  11.    to form the GDB symbol table.  A zero word where the beginning
  12.    of a segment is expected indicates there are no more segments.
  13.  
  14. Format of a symbol segment:
  15.  
  16.    The symbol segment begins with a word containing 1
  17.    if it is in the format described here.  Other formats may
  18.    be designed, with other code numbers.
  19.  
  20.    The segment contains many objects which point at each other.
  21.    The pointers are offsets in bytes from the beginning of the segment.
  22.    Thus, each segment can be loaded into core and its pointers relocated
  23.    to make valid in-core pointers.
  24.  
  25.    All the data objects in the segment can be found indirectly from
  26.    one of them, the root object, of type `struct symbol_root'.
  27.    It appears at the beginning of the segment.
  28.  
  29.    The total size of the segment, in bytes, appears as the `length'
  30.    field of this object.  This size includes the size of the
  31.    root object.
  32.  
  33.    All the object data types are defined here to contain pointer types
  34.    appropriate for in-core use on a relocated symbol segment.
  35.    Casts to and from type int are required for working with
  36.    unrelocated symbol segments such as are found in the file.
  37.  
  38.    The ldsymaddr word is filled in by the loader to contain
  39.    the offset (in bytes) within the ld symbol table
  40.    of the first nonglobal symbol from this compilation.
  41.    This makes it possible to match those symbols
  42.    (which contain line number information) reliably with
  43.    the segment they go with.
  44.  
  45.    Core addresses within the program that appear in the symbol segment
  46.    are not relocated by the loader.  They are inserted by the assembler
  47.    and apply to addresses as output by the assembler, so GDB must
  48.    relocate them when it loads the symbol segment.  It gets the information
  49.    on how to relocate from the textrel, datarel, bssrel, databeg and bssbeg
  50.    words of the root object.
  51.  
  52.    The words textrel, datarel and bssrel
  53.    are filled in by ld with the amounts to relocate within-the-file
  54.    text, data and bss addresses by; databeg and bssbeg can be
  55.    used to tell which kind of relocation an address needs.  */
  56.  
  57. enum language {language_c};
  58.  
  59. struct symbol_root
  60. {
  61.   int format;            /* Data format version */
  62.   int length;            /* # bytes in this symbol segment */
  63.   int ldsymoff;            /* Offset in ld symtab of this file's syms */
  64.   int textrel;            /* Relocation for text addresses */
  65.   int datarel;            /* Relocation for data addresses */
  66.   int bssrel;            /* Relocation for bss addresses */
  67.   char *filename;        /* Name of main source file compiled */
  68.   char *filedir;        /* Name of directory it was reached from */
  69.   struct blockvector *blockvector; /* Vector of all symbol-naming blocks */
  70.   struct typevector *typevector; /* Vector of all data types */
  71.   enum language language;    /* Code identifying the language used */
  72.   char *version;        /* Version info.  Not fully specified */
  73.   char *compilation;        /* Compilation info.  Not fully specified */
  74.   int databeg;            /* Address within the file of data start */
  75.   int bssbeg;            /* Address within the file of bss start */
  76.   struct sourcevector *sourcevector; /* Vector of line-number info */
  77. };
  78.  
  79. /* All data types of symbols in the compiled program
  80.    are represented by `struct type' objects.
  81.    All of these objects are pointed to by the typevector.
  82.    The type vector may have empty slots that contain zero.  */
  83.  
  84. struct typevector
  85. {
  86.   int length;            /* Number of types described */
  87.   struct type *type[1];
  88. };
  89.  
  90. /* Different kinds of data types are distinguished by the `code' field.  */
  91.  
  92. enum type_code
  93. {
  94.   TYPE_CODE_UNDEF,        /* Not used; catches errors */
  95.   TYPE_CODE_PTR,        /* Pointer type */
  96.   TYPE_CODE_ARRAY,        /* Array type, lower bound zero */
  97.   TYPE_CODE_STRUCT,        /* C struct or Pascal record */
  98.   TYPE_CODE_UNION,        /* C union or Pascal variant part */
  99.   TYPE_CODE_ENUM,        /* Enumeration type */
  100.   TYPE_CODE_FUNC,        /* Function type */
  101.   TYPE_CODE_INT,        /* Integer type */
  102.   TYPE_CODE_FLT,        /* Floating type */
  103.   TYPE_CODE_VOID,        /* Void type (values zero length) */
  104.   TYPE_CODE_SET,        /* Pascal sets */
  105.   TYPE_CODE_RANGE,        /* Range (integers within spec'd bounds) */
  106.   TYPE_CODE_PASCAL_ARRAY    /* Array with explicit type of index */
  107. };
  108.  
  109. /* This appears in a type's flags word for an unsigned integer type.  */
  110. #define TYPE_FLAG_UNSIGNED 1
  111.  
  112. /* Other flag bits are used with GDB.  */
  113.  
  114. struct type
  115. {
  116.   /* Code for kind of type */
  117.   enum type_code code;
  118.   /* Name of this type, or zero if none.
  119.      This is used for printing only.
  120.      Type names specified as input are defined by symbols.  */
  121.   char *name;
  122.   /* Length in bytes of storage for a value of this type */
  123.   int length;
  124.   /* For a pointer type, describes the type of object pointed to.
  125.      For an array type, describes the type of the elements.
  126.      For a function type, describes the type of the value.
  127.      Unused otherwise.  */
  128.   struct type *target_type;
  129.   /* Type that is a pointer to this type.
  130.      Zero if no such pointer-to type is known yet.
  131.      The debugger may add the address of such a type
  132.      if it has to construct one later.  */ 
  133.   struct type *pointer_type;
  134.   /* Type that is a function returning this type.
  135.      Zero if no such function type is known here.
  136.      The debugger may add the address of such a type
  137.      if it has to construct one later.  */
  138.   struct type *function_type;
  139.   /* Flags about this type.  */
  140.   short flags;
  141.   /* Number of fields described for this type */
  142.   short nfields;
  143.   /* For structure and union types, a description of each field.
  144.      For set and pascal array types, there is one "field",
  145.      whose type is the domain type of the set or array.
  146.      For range types, there are two "fields",
  147.      the minimum and maximum values (both inclusive).
  148.      For enum types, each possible value is described by one "field".
  149.      For range types, there are two "fields", that record constant values
  150.      (inclusive) for the minimum and maximum.
  151.  
  152.      Using a pointer to a separate array of fields
  153.      allows all types to have the same size, which is useful
  154.      because we can allocate the space for a type before
  155.      we know what to put in it.  */
  156.   struct field
  157.     {
  158.       /* Position of this field, counting in bits from start of
  159.      containing structure.  For a function type, this is the
  160.      position in the argument list of this argument.
  161.      For a range bound or enum value, this is the value itself.  */
  162.       int bitpos;
  163.       /* Size of this field, in bits, or zero if not packed.
  164.      For an unpacked field, the field's type's length
  165.      says how many bytes the field occupies.  */
  166.       int bitsize;
  167.       /* In a struct or enum type, type of this field.
  168.      In a function type, type of this argument.
  169.      In an array type, the domain-type of the array.  */
  170.       struct type *type;
  171.       /* Name of field, value or argument.
  172.      Zero for range bounds and array domains.  */
  173.       char *name;
  174.     } *fields;
  175. };
  176.  
  177. /* All of the name-scope contours of the program
  178.    are represented by `struct block' objects.
  179.    All of these objects are pointed to by the blockvector.
  180.  
  181.    Each block represents one name scope.
  182.    Each lexical context has its own block.
  183.  
  184.    The first two blocks in the blockvector are special.
  185.    The first one contains all the symbols defined in this compilation
  186.    whose scope is the entire program linked together.
  187.    The second one contains all the symbols whose scope is the
  188.    entire compilation excluding other separate compilations.
  189.    In C, these correspond to global symbols and static symbols.
  190.  
  191.    Each block records a range of core addresses for the code that
  192.    is in the scope of the block.  The first two special blocks
  193.    give, for the range of code, the entire range of code produced
  194.    by the compilation that the symbol segment belongs to.
  195.  
  196.    The blocks appear in the blockvector
  197.    in order of increasing starting-address,
  198.    and, wi */
  199.     }
  200.   value;
  201. };
  202.  
  203. /* Source-file information.
  204.    This describes the relation between source files and line numbers
  205.    and addresses in the program text.  */
  206.  
  207. struct sourcevector
  208. {
  209.   int length;            /* Number of source files described */
  210.   struct source *source[1];    /* Descriptions of the files */
  211. };
  212.  
  213. /* Line number and address of one line.  */
  214.  
  215. struct line
  216. {
  217.   int linenum;
  218.   int address;
  219. };
  220.  
  221. /* All the information on one source file.  */
  222.  
  223. struct source
  224. {
  225.   char *name;            /* Name of file */
  226.   int nlines;            /* Number of lines that follow */
  227.   struct line lines[1];    /* Information on each line */
  228. };
  229.